<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('sidebar.borrowBack')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('loanAfterManage.crumbsOne')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('operationList.crumbsTwo')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- -------------搜索查询栏------------------------ -->
    <search 
			:searchData="searchData" 
			@search="search" 
			:searchRight="true"
			:outputRight="false"
    ></search>
    <!-- -------------表单显示栏------------------------ -->
    <!-- <div class="table" v-if="$store.state.common.permiss.includes('RIGHT_ACCOUNT_LENDING_LIST')"> -->
    <div class="table">
      <template>
        <el-table :data="tableData" stripe size="small" v-loading="loadFlag">
          <el-table-column align="center" prop="orderId" :label="$t('public.orderId')"></el-table-column>
          <el-table-column align="center" prop="userName" :label="$t('public.userName')"></el-table-column>
          <el-table-column align="center" prop="userPhone" :label="$t('public.userPhone')"></el-table-column>
          <el-table-column align="center" prop="loanAmount" :label="$t('public.no24')"></el-table-column>
          <el-table-column align="center" prop="overdueDays" :label="$t('public.no28')"></el-table-column>
          <el-table-column align="center" prop="overdueInterest" :label="$t('public.no56')"></el-table-column>
          <el-table-column align="center" prop="refundAmount" :label="$t('public.no65')"></el-table-column>
          <el-table-column align="center" prop="waitAmount" :label="$t('loanAfterManage.waitAmount')"></el-table-column>
          <el-table-column align="center" prop="deductionAmount" :label="$t('loanAfterManage.no11')">
            <template slot-scope="scope">
              <span v-if="scope.row.deductionAmount" class="blue" @click="showLog(scope.row.orderId)">{{scope.row.deductionAmount}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="lastTime" :label="$t('loanAfterManage.time')"></el-table-column>
          <el-table-column align="center" prop="createTime" :label="$t('public.no71')"></el-table-column>
          <el-table-column align="center" prop="status" :label="$t('loanAfterManage.status')">
            <template slot-scope="scope">
              <span>{{$t($store.getters.operationStatus(scope.row.status))}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="maxOverdueDays" :label="$t('new.no77')"></el-table-column>
          <el-table-column align="center" prop="type" :label="$t('new.no78')"></el-table-column>
          <!-- <el-table-column align="center" prop="callStartTime" :label="$t('new.no83')"></el-table-column> -->
          <!-- <el-table-column align="center" prop="callStatus" :label="$t('new.no84')"></el-table-column> -->
          <el-table-column fixed="right" align="center" prop="operation" :label="$t('public.operation')" min-width="120">
            <template slot-scope="scope">
              <span class="table_opr" v-if="scope.row.status!=100" 
                @click="detail(scope.row.userId,scope.row.orderId,scope.row.waitAmount)">
                {{$t('operationList.no1')}}
              </span>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>
    <div class="foot"></div>

    <!-- ------------------ 点击转派弹窗开始 -------------------- -->
    <el-dialog :title="$t('loanAfterManage.no10')" :visible.sync="remissionFlag" width="80%">
      <div class="table">
      <template>
        <el-table :data="logData" stripe size="small" >
          <el-table-column align="center" prop="orderId" :label="$t('public.operation')">
            <template>{{$t('loanAfterManage.no13')}}</template>
          </el-table-column>
          <el-table-column align="center" prop="operateTime" :label="$t('loanAfterManage.no9')"></el-table-column>
          <el-table-column align="center" prop="adminName" :label="$t('loanAfterManage.no8')"></el-table-column>
          <el-table-column align="center" prop="reduceAmount" :label="$t('operationDetail.no48')"></el-table-column>
          <el-table-column align="center" prop="remark" :label="$t('loanAfterManage.no12')"></el-table-column>
        </el-table>
      </template>
    </div>
    </el-dialog>
    <!-- ------------------ 点击转派弹窗结束 -------------------- -->

  </div>
</template>
<script>
export default {
  name: 'myCollectionList',
  data () {
    const searchData=[
      {
        type: 'input',
        label: 'public.orderId',
        attr: 'orderId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.name',
        attr: 'userName',
        value: ''
      },{
        type: 'input',
        label: 'public.userTel',
        attr: 'phone',
        value: ''
      }, {
        type: 'select',
        attr: 'status',
        label: 'loanAfterManage.status',
        option: this.$store.state.options.collection_option,
        value: '',
        langFlag: true,
      },{
        type: 'doubleInput',
        label: 'public.no28',
        attr: ['overdueDaysBegin','overdueDaysEnd'],
        value: []
      },{
        type: 'doubleInput',
        label: 'new.no77',
        attr: ['maxOverdueDaysBegin','maxOverdueDaysEnd'],
        value: []
      },{
        type: 'doubleInput',
        label: 'new.no78',
        attr: ['repeatCountBegin','repeatCountEnd'],
        value: []
      }, {
        type: 'rangePicker',
        label: 'loanAfterManage.time',
        attr: 'collectionTime',
        value: [],
      },{
        type: 'rangePicker',
        label: 'public.no71',
        attr: 'createTime',
        value: [],
      },
      // {
      //   type: 'rangePicker',
      //   label: 'new.no87',
      //   attr: 'callTime',
      //   value: [],
      // },
      {
        type: 'select',
        attr: 'callStatus',
        label: 'new.no88',
        option: this.$store.state.options.groupCalls_options,
        value: '',
        langFlag: true
      }]
    return {
      flag: true,
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchData:searchData,
      formInline: {},// 用户查询信息数据对应字段
      tableData: [],// 用户信息数据模拟
      remissionFlag: false,
      logData: [],
      logFlag: false
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search(search) { // 搜索
      console.log(search);
      this.formInline = {
        orderId: search.orderId,
        userName:search.userName,
        phone: search.phone,
        status: search.status,
        overdueDaysBegin: search.overdueDaysBegin,
        overdueDaysEnd: search.overdueDaysEnd,
        maxOverdueDaysBegin: search.maxOverdueDaysBegin,
        maxOverdueDaysEnd: search.maxOverdueDaysEnd,
        repeatCountBegin: search.repeatCountBegin,
        repeatCountEnd: search.repeatCountEnd,
        createTimeBegin: search.createTime?search.createTime[0]:'',
        createTimeEnd: search.createTime?search.createTime[1]:'',
        collectionTimeBegin: search.collectionTime?search.collectionTime[0]:'',
        collectionTimeEnd: search.collectionTime?search.collectionTime[1]:'',
        callStartTime: search.callTime?search.callTime[0]:'',
        callEndTime: search.callTime?search.callTime[1]:'',
        callStatus:search.callStatus,
        appName:search.appName,
        appPackage:search.appPackage
      };
      if (this.flag) {
        this.pagination.currentPage = 1;
        this.flag = false;
        this.getTableData();
      }
      
    },
    getTableData () { // 放款列表获取
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          partnerId:sessionStorage.partnerId,
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.collection_mylist, option).then(res => {
        this.flag = true;
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.message)
        }
        this.loadFlag = false;
      })
    },
    detail (userId, orderId,waitAmount) { // 查看详情点击操作
      this.$router.push({path: '/CollectionDetail', query: {userId, orderId,waitAmount,'collection':1}});
    },
    showLog(id){
      let option = {
        pageNum:0,
        pageSize:20,
        param: {
          orderId: id
        }       
      }
      this.$axios.post(this.$action.collection_concessions, option).then(res => {
        this.flag = true;
        if (res.code == 200) {
          this.logData = res.data.list;
          this.remissionFlag = true
        }else{
          this.$globalMsg.error(res.message)
        }
      })
    }
  },
  mounted () {
    this.getTableData();
  }
}
</script>
<style scoped lang="scss"></style>
